package Integrity;

import java.io.IOException;

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPathExpressionException;

import org.xml.sax.SAXException;


public class DataInt_ErrorChecking_Interface {
	
	public DataInt_ErrorChecking_Interface(String usID, String bsID, String fl) throws XPathExpressionException, ParserConfigurationException, SAXException, IOException, Exception{
		
		UserID = usID;
        BillingSiteID = bsID;
		XmlFileName = fl;
		extract = new StatementData(XmlFileName);
		
	}
	public Result createResult() throws Exception{
		Scaper_APS_Errors_Checks saec = new Scaper_APS_Errors_Checks(extract);	
		if (saec.XMLhas_ErrorCode() == false){
			
			Data_Int_Checks dic = new Data_Int_Checks(extract);
			resultErrorCode = dic.getErrorCode();
			if (resultErrorCode.equals("NONE")){
				resultErrorType = "NONE";				
			}
			else{
			resultErrorType = "DIC";
			extract.set_scraped_error_code(resultErrorCode);
			}
		}
		else {
			resultErrorCode = extract.get_scraped_error_code();
			resultErrorType = "ERR";
		}
		
		factory = new StatementFactory (UserID,BillingSiteID,resultErrorType,extract);
		result = factory.createResult();
		return result;
	}
	public Result getResult(){
		return result;	 
	}
	
	 private String XmlFileName;
	 private String UserID;
     private String BillingSiteID;
	 private String resultErrorType;
	 private String resultErrorCode = "NONE";
	 StatementData extract;
	 
	 StatementFactory factory;
	 Result result;
}
